Quote:Original post by SpoonbenderQuote:Original post by mfk_1868
By this way I am thinking of minimizing the database query number to minimum. Is this a good idea?
Yep, that's pretty much rule #1 in database queries. Don't use two queries if you can manage with one. Crossing the boundary from your external application to the database is expensive, so use as few queries as possible.
Not necessarily. In some cases, especially when using GROUP BY, 2 queries will be stupidly faster than one (think 10 minutes vs less than 1 second) I learned this the hard way :/ The number of queries doesn't matter as much as the quality of them.